<%@page contentType="text/html; charset=UTF-8" %>
<%@page import="ChartDirector.*" %>
<%
// The data for the chart
double[] data0 = {389000, 67000, 42000, 54000, 38000};
double[] data1 = {0.10, 0.12, 0.085, 0.067, -0.035};
String[] labels = {"景洪供电有限公司", "勐海润安", "农垦", "葫芦岛", "南果河"};

// 创建一个XYChart对象，大小为300X180
XYChart c = new XYChart(400, 280);
c.setBackground(0xefeff0);
// Set the plot area at (50, 20) and of size 200 x 130 pixels
c.setPlotArea(70, 20, 200, 130);

// 添加标题
//c.addTitle("购电量分析图", "宋体", 8);
c.setDefaultFonts("simsun.ttc", "simhei.ttc");
// Set the labels on the x axis.
c.xAxis().setLabels(labels);
c.xAxis().setLabelStyle("仿宋",8,0x000000,50);
// 添加Y轴主坐标单位
c.yAxis().setTitle("万千瓦时");

// Set the axis, label and title colors for the primary y axis to red (0xc00000) to
// match the first data set
c.yAxis().setColors(0x000000, 0x000000, 0x000000);

// Add a title to the secondary (right) y axis
//c.yAxis2().setTitle("Throughtput (MBytes)");

// set the axis, label and title colors for the primary y axis to green (0x008000) to
// match the second data set
c.yAxis2().setColors(0x979797, 0x979797, 0x979797);

// Add a line layer to for the first data set using red (0xc00000) color with a line
// width to 3 pixels
LineLayer lineLayer = c.addLineLayer(data0, 0xFF6657);
lineLayer.setLineWidth(2);

// tool tip for the line layer
lineLayer.setHTMLImageMap("", "", "title='Packet Drop Rate on {xLabel}: {value} pps'"
    );

// Add a bar layer to for the second data set using green (0x00C000) color. Bind the
// second data set to the secondary (right) y axis
BarLayer barLayer = c.addBarLayer(data1, 0x344B6D);
barLayer.setUseYAxis2();

// tool tip for the bar layer
barLayer.setHTMLImageMap("", "", "title='Throughput on {xLabel}: {value} MBytes'");

// Output the chart
String chart1URL = c.makeSession(request, "chart1");

// include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("");
%>
<html>
<body style="margin:5px 0px 0px 5px">
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Dual Y-Axis
</div>
<hr color="#000080">
<div style="font-size:9pt; font-family:verdana; margin-bottom:1.5em">
    <a href="viewsource.jsp?file=<%=request.getServletPath()%>">View Source Code</a>
</div>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
    usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
</body>
</html>
